package com.demo.mapper;

import com.demo.handler.UserStatusTypeHandler;
import com.demo.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper2 {

    @Results(id = "userMap", value = {
            @Result(id=true,property = "id",column = "uid"),
            @Result(property = "name",column = "uname"),
            @Result(property = "age",column = "uage"),
            @Result(property = "status",column = "status",typeHandler = UserStatusTypeHandler.class)
    })
    @Select("select * from users where uid=#{id}")
    User findById(int id);

    @ResultMap(value = "userMap")
    @Select("select * from users")
    List<User> findAll();

    //修改用户状态
    @Update("update users set status=#{status,typeHandler=com.demo.handler.UserStatusTypeHandler} " +
            "where uid=#{id}")
    int setStatus(User user);
}
